// source --> http://nichirinnotsubasa.com/wp-content/plugins/simple-download-monitor/js/sdm_wp_scripts.js?ver=4.9
// Simple Download Monitor frontend scripts
jQuery(document).ready(function($) {
// Populate all nested titles and links
$('li.sdm_cat').each(function() {
var $this = $(this);
this_slug = $this.attr('id');
this_id = $this.children('.sdm_cat_title').attr('id');
// Run ajax
$.post(
sdm_ajax_script.ajaxurl,
{
action: 'sdm_pop_cats',
cat_slug: this_slug,
parent_id: this_id
},
function(response) {
// Loop array returned from ajax function
$.each(response.final_array, function(key, value) {
// Populate each matched post title and permalink
$this.children('.sdm_placeholder').append('' + value['title'] + '');
});
$this.children('span').append('↨');
}
);
});
// Hide results on page load
$('li.sdm_cat').children('.sdm_placeholder').hide();
// Slide toggle for each list item
$('body').on('click', '.sdm_cat_title', function(e) {
// If there is any html.. then we have more elements
if ($(this).next().html() != '') {
$(this).next().slideToggle(); // toggle div titles
}
});
});